package com.dodo.blog.model;

import com.dodo.blog.ui.component.input.Renderable;

import javax.persistence.Entity;
import javax.validation.constraints.NotNull;

/**
 * @author <a href="mailto:pohorelec@comvai.com">Jozef Pohorelec</a>
 */
@Entity
public class Tag
        extends BaseEntity
        implements Renderable
{
    private static final long serialVersionUID = 1L;

    @NotNull
    private String name;

    private String normalizedName;

    public String getName()
    {
        return name;
    }

    public void setName( String name )
    {
        this.name = name;
        this.normalizedName = name.toLowerCase().replace( " ", "-" );
    }

    public String getNormalizedName()
    {
        return normalizedName;
    }

    @Override
    public String toString()
    {
        return "Tag{" +
                "name='" + name + '\'' +
                '}';
    }

    @Override
    public String getLabel()
    {
        return name;
    }
}